//index.js

Page({
  data:{
    maxlengthshu: '-1',//输入文本的长度限制，-1是无限制
    autofocus: false,
    fasongbtndisabled: true,
    liuyanblock: false,
    liuyantitle: '发表留言',
    liuyanstate: 1,
  },
  
  onLoad: function () {
   
  },
  //获取内容文字
  bindTextAreaBlur: function (e) {
    var that = this
    var thistexttag = e.detail.value

    if (thistexttag !== '') {
      that.setData({
        fasongbtndisabled: false
      })
    } else {
      that.setData({
        fasongbtndisabled: true
      })
    }
  },
  //打开评论
  pinglunblockopen: function (e) {
    var that = this
    var foruser = e.currentTarget.dataset.username
    var liuyanblocktag = that.data.liuyanblock

    if (liuyanblocktag == false) {
      that.setData({
        liuyanblock: true,
        autofocus: true,
      })
    } else {
      that.setData({
        liuyanblock: false,
        foruser: '',
        liuyantitle: '发表留言',
        liuyanstate: 1,
        liuyanforuser: '',
        autofocus: false,
      })
    }

    if (foruser !== '') {
      that.setData({
        liuyantitle: '回复留言',
        liuyanstate: 2,
        liuyanforuser: foruser,
      })
    } else {
      that.setData({
        liuyantitle: '发表留言',
        liuyanstate: 1,
        liuyanforuser: '',
      })
    }

  },
  //关闭评论区
  pinglunblockclose: function () {
    var that = this
    that.setData({
      liuyanblock: false,
      foruser: '',
      liuyantitle: '发表留言',
      liuyanstate: 1,
      liuyanforuser: '',
      autofocus: false,
    })
  },
  
})
